import { TColumn } from '@/components/editable-excel-table';
import { DataIndex } from '../reducer/types';

/**
 * 安全地将字符串转换为DataIndex类型
 */
export function toDataIndex<C extends TColumn>(dataIndex: string): DataIndex<C> {
    return dataIndex as DataIndex<C>;
}

/**
 * 检查是否为有效的DataIndex
 */
export function isValidDataIndex<C extends TColumn>(dataIndex: string): dataIndex is DataIndex<C> {
    return typeof dataIndex === 'string' && dataIndex.length > 0;
}
